/* Task : Write and test a program for an embedded system using a microcontroller to interact with input and / or output devices and communicate with wired or wireless devices. Flash LED and display something on serial monitor and OLED Display when the Push button is pressed. Hardware assembly description Development Board : Seeed Studio XIAO RP2040 Inputs : PIN D7 Push button Outputs : PIN D0 Blue LED Wired Communication : I2C with OLED Display Created on : 14 Feb 2026 Author : Abhishek Modification History: 17 Feb 2026 Library installed for this code are U8g2 by Oliver. (You can install Library Sketch > Include Library > Manage Libraries > Search U8g2 > Install) Arduino Programming Reference : https://docs.arduino.cc/language-reference/ Seed Studio Reference : https://wiki.seeedstudio.com/XIAO-RP2040-with-Arduino/ */ #include // this header file provides access to all the standard, built-in Arduino functions, variables, and constants. Without it, the compiler would not recognize basic Arduino commands. it is must include for VS Code and other programing environments. #include // this header file provides a preprocessor directive in Arduino/C++ programming that imports the U8g2 library. #ifdef U8X8_HAVE_HW_SPI #include #endif #ifdef U8X8_HAVE_HW_I2C // this header checks if token U8X8_HAVE_HW_I2C has been defined earlier and check if OLED display supports I2C communication, if yes then include Wire.h library. #include #endif U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); const int BlueLED = D0; // the number of Blue LED pin const int PushButton = D7; // the number of PushB Button pin, note that here const mean "read-only" variable its value is set at initialization and cannot be changed later in the program, which helps prevent accidental modification of important values. int ButtonStatus = LOW; // Variable for reading the pushbutton status int i; // counter for for loop void setup() // the setup function runs once when you press reset or power the board { pinMode(BlueLED, OUTPUT); // initialize digital PIN D0 as output pinMode(PushButton, INPUT); // initialize digital PIN D7 as Input Serial.begin(115200); // Set the data rate 115200 baud (bits per second) for serial data transmission. Wire.begin(); // Activates the I2C hardware peripheral, Assigns SDA & SCL pins to I2C mode, Gets ready to send/receive data u8g2.begin(); // initialize the display and prepare it for drawing with u8g2 Arduino graphics library } void loop() // the loop function runs over and over again forever { ButtonStatus = digitalRead(PushButton); //read the digital status of Push Button if (ButtonStatus == LOW) //if Push Button Status in LOW then flash the LED as Airbus Strobe lights pattern for 5 times { for (i = 0; i<10; i++) { Serial.println("FABLAB Kerala!"); // this prints "FABLAB Kerala!" on the serial monitor digitalWrite(BlueLED, HIGH); // turn ON Blue LED delay(100); // delay of 0.1 second digitalWrite(BlueLED, LOW); // turn OFF Blue LED delay(100); // delay of 0.1 second digitalWrite(BlueLED, HIGH); // turn ON Blue LED delay(100); // delay of 0.1 second digitalWrite(BlueLED, LOW); // turn OFF Blue LED delay(400); // delay of 0.7 second u8g2.setFont(u8g2_font_ncenB08_tr); // ncenB: New Century Schoolbook (font name), Bold (weight). Height of the font is 8 pixels u8g2.drawStr(0,10,"Airbus Strobe light.."); // draw string at x = 0 and y = 10 u8g2.drawStr(0,30,"By"); // draw string at x = 0 and y = 30 u8g2.drawStr(0,50,"FAB LAB Kerala!"); // draw string at x = 0 and y = 50 u8g2.sendBuffer(); // transfer internal memory to the display u8g2.clearBuffer(); // clear the internal memory delay(700); } u8g2.sendBuffer(); // transfer internal memory to the display } else { digitalWrite(BlueLED, LOW); // turn Off Red LED } }